home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / processor-keymap.xml < prev    next >
Extensible Markup Language  |  2010-01-15  |  5KB  |  199 lines

  1. <?xml version="1.0"?>
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  6.  
  7. <bindings xmlns="http://www.mozilla.org/xbl"
  8.     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  9.     xmlns:html="http://www.w3.org/1999/xhtml"
  10.     xmlns:xbl="http://www.mozilla.org/xbl">
  11.  
  12.     <binding id="ProcessorKeyMap" extends="widgets.xml#widget">
  13.  
  14.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  15.         
  16.             <vbox flex="1">
  17.                 <hbox>
  18.                      <ProcessorMenulist anonid="xProcessors" oncommand="this.parentNode.parentNode.parentNode.update()"/>
  19.                     <spacer flex="1"/>
  20.                     <button label="&proc-keymap.revert;" oncommand="this.parentNode.parentNode.parentNode.revertToDefault()"/>
  21.                 </hbox>
  22.                 <spacer flex="1"/>
  23.                 <grid flex="1">
  24.                     <columns>
  25.                         <column flex="0"/>
  26.                         <column flex="1"/>
  27.                     </columns>
  28.                     <rows>
  29.                         <row>
  30.                             <label value="&proc-keymap.provider;"/>
  31.                             <description anonid="xProvider" style="font-style: italic;"/>
  32.                         </row>
  33.                         <row>
  34.                             <label value="&proc-keymap.description;"/>
  35.                             <description anonid="xDescription" style="font-style: italic;"/>
  36.                         </row>
  37.                         <row>
  38.                             <label value="&proc-keymap.current-key;"/>
  39.                             <description anonid="xKeystr" style="font-style: italic;"/>
  40.                         </row>
  41.                     </rows>
  42.                 </grid>
  43.                 <spacer flex="1"/>
  44.                 <hrow>
  45.                     <spacer flex="1"/>
  46.                     <button label="&proc-keymap.hold-assign;" oncommand="this.parentNode.parentNode.parentNode.assign(event)"/>
  47.                     <button label="&proc-keymap.unmap;" oncommand="this.parentNode.parentNode.parentNode.unmap()"/>
  48.                 </hrow>
  49.             </vbox>
  50.  
  51.             <children style="display: none;"/>
  52.         </xbl:content>
  53.  
  54.         <implementation>
  55.  
  56.             <constructor>
  57.                 <![CDATA[
  58. this.core=Components.classes["@downloadhelper.net/core;1"].
  59.     getService(Components.interfaces.dhICore);
  60. this.processors={};
  61. var processors=this.core.getProcessors();
  62. var i=processors.enumerate();
  63. while(i.hasMoreElements()) {
  64.     var processor=i.getNext().QueryInterface(Components.interfaces.dhIProcessor);
  65.     this.processors[processor.name]=processor;
  66. }
  67. this.value=this.getAttribute("value");
  68.                 ]]>
  69.             </constructor>
  70.             
  71.             <method name="revertToDefault">
  72.                 <body>
  73.                 <![CDATA[
  74. this.value="0:download,2:convert-choice,3:quick-download";
  75.                 ]]>
  76.                 </body>
  77.             </method>
  78.             
  79.             <method name="assign">
  80.                 <parameter name="event"/>
  81.                 <body>
  82.                 <![CDATA[
  83. var processor=this.processors[this.xProcessors.value];
  84. if(!processor)
  85.     return;
  86. var key=(event.ctrlKey?1:0) |
  87.     (event.shiftKey?2:0) |
  88.     (event.altKey?4:0) |
  89.     (event.metaKey?8:0);
  90. if(this.keymap[key]==processor.name)
  91.     return;
  92. if(this.keymap[key]) {
  93.     var keyStr=this.getKeyString(key);
  94.     var message=Util.getFText("message.processor.overwrite-key",[keyStr,this.processors[this.keymap[key]].title,keyStr],3);
  95.     var r=confirm(message);
  96.     if(r==false)
  97.         return;
  98. }
  99. this.unmap();
  100. this.keymap[key]=processor.name;
  101. this.update();
  102.                 ]]>
  103.                 </body>
  104.             </method>
  105.  
  106.             <method name="unmap">
  107.                 <body>
  108.                 <![CDATA[
  109. var processor=this.processors[this.xProcessors.value];
  110. if(!processor)
  111.     return;
  112. for(var i in this.keymap) {
  113.     if(this.keymap[i]==processor.name) {
  114.         delete this.keymap[i];
  115.         this.update();
  116.         return;
  117.     }
  118. }
  119.                 ]]>
  120.                 </body>
  121.             </method>
  122.  
  123.             <method name="update">
  124.                 <body>
  125.                 <![CDATA[
  126. var processor=this.processors[this.xProcessors.value];
  127. if(!processor)
  128.     return;
  129. this.xProvider.setAttribute("value",processor.provider);
  130. while(this.xDescription.firstChild)
  131.     this.xDescription.removeChild(this.xDescription.firstChild);
  132. var description=document.createTextNode(processor.description);
  133. this.xDescription.appendChild(description);
  134.  
  135. var key=-1;
  136. for(var k in this.keymap) {
  137.     if(this.keymap[k]==processor.name) {
  138.         key=k;
  139.         break;
  140.     }
  141. }
  142. var keyStr=this.getKeyString(key);
  143. this.xKeystr.setAttribute("value",keyStr);
  144.                 ]]>
  145.                 </body>
  146.             </method>
  147.             
  148.             <method name="getKeyString">
  149.                 <parameter name="key"/>
  150.                 <body>
  151.                 <![CDATA[
  152. var keyStr=Util.getText("processor.quickkey.nokey");
  153. if(key!=-1) {
  154.     var kp=[];
  155.     for(var k=0; k<4; k++) {
  156.         if((1<<k)&key)
  157.             kp.push(Util.getText("processor.quickkey.key"+k));
  158.     }
  159.     kp.push(Util.getText("processor.quickkey.click"));
  160.     keyStr=kp.join("+");
  161. }
  162. return keyStr;
  163.                 ]]>
  164.                 </body>
  165.             </method>
  166.  
  167.  
  168.             <property name="value">
  169.                 <getter>
  170.                 <![CDATA[
  171. var p=[];
  172. for(var i in this.keymap) {
  173.     p.push(i+":"+this.keymap[i]);
  174. }
  175. return p.join(",");
  176.                 ]]>
  177.                 </getter>
  178.                 <setter>
  179.                 <![CDATA[
  180. this.keymap={};
  181. if(val==null)
  182.     return;
  183. var p1=val.split(",");
  184. for(var i in p1) {
  185.     var p2=p1[i].split(":");
  186.     if(p2.length==2 && this.processors[p2[1]])
  187.         this.keymap[parseInt(p2[0])]=p2[1];
  188. }
  189. setTimeout(function(_this) { _this.update(); },0,this);
  190.                 ]]>
  191.                 </setter>
  192.             </property>
  193.  
  194.          </implementation>
  195.                 
  196.     </binding>
  197.  
  198. </bindings>
  199.